#!/bin/bash
echo
echo "* Setting up your environment..."
echo
#-----------------------------------------------------------------------------
#the main working directory for this build of the code
export WORKING_DIR=$(pwd)
echo "Working directory = " $WORKING_DIR

# Set your ROOTSYS, PYTHONDIR and LD_LIBRARY_PATH here
MY_ROOTSYS=/usr/local/src/root_5_32_00/root/
MY_PYTHONPATH=$WORKING_DIR/lib
MY_LD_LIBRARY_PATH=$MY_ROOTSYS/lib:/usr/lib/python:$WORKING_DIR/lib:/usr/local/lib
#
#-----------------------------------------------------------------------------
#
# Setup ROOTSYS
#===============
#check is a ROOTSYS is defined (needed to run root and
#also make the root compile flags work when added to the
#path).
echo "-> ROOTSYS - needed for ROOT."
if [ -z $ROOTSYS ]; then
    echo "---->! No ROOTSYS defined!"
    export ROOTSYS=$MY_ROOTSYS
else
    echo "---->! ROOTSYS already defined."
fi
echo "-->* ROOTSYS is " $ROOTSYS
#--------------------------------------------
#
# Set up PATH
#=============
# Check PATH for /root/bin, add it if it isn't there
echo "-> Checking PATH for ROOT..."
PATH_HAS_ROOT=$(echo $PATH | grep /root/bin)
if [ -z $PATH_HAS_ROOT ]; then
    echo "---->! PATH does not have /root/bin."
    export PATH=$ROOTSYS/bin:$PATH
else
    echo "---->! PATH already has a /root/bin"
fi
echo "-->* PATH is: " $PATH

# Set up LD_LIBRARY_PATH
#will almost certainly need to come back to this...
export LD_LIBRARY_PATH=/usr/local/lib:$ROOTSYS/lib:$WORKING_DIR/lib:$PYTHIAPATH/lib
#export TMP_LDPATH_VAR=$MY_LD_LIBRARY_PATH
echo "LD_LIBRARY_PATH is:" $LD_LIBRARY_PATH
#
# Set up PYTHONPATH
#needed for determining where to look for import modules.
export PYTHONPATH=$ROOTSYS/lib:$MY_PYTHONPATH
echo "-> PYTHONPATH: for finding Python modules"
echo "-->* PYTHONPATH is:" $PYTHONPATH
echo
echo "* Set-up complete!"
echo
